#include <iostream>
#include <map>
using namespace std;


/**
 * 小黑面试
 * @return 
 */
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        mp[x]++;
    }
    int first=0, mx = 0;
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it->second >= mx) {
            mx = it->second;
            first = it->first;
        }
    }
    cout << first << " " << mx;

    return 0;
}